﻿using School;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace School
{
    [TestClass()]
    public class CourseTest
    {
        [TestMethod()]
        [ExpectedException(typeof(ArgumentException))]
        public void AddWithSameNumberTest()
        {
            Course target = new Course();
            target.Add(new Student("Pesho", 11111));
            target.Add(new Student("Kiro", 11111));
        }

        [TestMethod()]
        [ExpectedException(typeof(IndexOutOfRangeException))]
        public void AddMoreThanAllowedTest()
        {
            Course target = new Course();
            for (int i = 0; i < 7; i++)
            {
                target.Add(new Student("Pesho", 11111 + i));
                target.Add(new Student("Ivan", 33333 + i));
                target.Add(new Student("Georgi", 22222 + i));
                target.Add(new Student("Kolio", 44444 + i));
            }
            target.Add(new Student("Pesho", 11119));
            target.Add(new Student("Ivan", 33340));
            target.Add(new Student("Georgi", 22229));
            target.Add(new Student("Kolio", 44451));
        }

        [TestMethod()]
        public void StudentsInTheCourseTest()
        {
            Course target = new Course();
            target.Add(new Student("Pesho", 11111));
            target.Add(new Student("Kiro", 22222));
            Dictionary<int, Student> expected = new Dictionary<int, Student>();
            expected.Add(11111, new Student("Pesho", 11111));
            expected.Add(22222, new Student("Kiro", 22222));
            Dictionary<int, Student> actual;
            target.StudentsInTheCourse = expected;
            actual = target.StudentsInTheCourse;
            Assert.AreEqual(expected, actual);
        }
    }
}
